/**
 * zmn 花名册模块-工程师升级考试地址
 * @author tanghongjun
 * @since 2020-08-19 11:18:36
 */
layui.define(['index', 'form', 'table', 'laypage', 'layedit'], function (exports) {
    var $ = layui.$;
    var form = layui.form;
    var layer = layui.layer;
    var table = layui.table;
    var laypage = layui.laypage;
    var layedit = layui.layedit;

    form.render(null, "zmn-form");

    // 提交
    form.on('submit(zmn-form-submit)', function(obj){
        var data = obj.field;
        var url = "/product/engineerexamineurl/addEdit.action";

        if(zmnUtil.isEmptyNull(data.primaryLeaveUrl) && zmnUtil.isEmptyNull(data.middleRankUrl)
            && zmnUtil.isEmptyNull(data.theSeniorUrl) && zmnUtil.isEmptyNull(data.theSuperUrl) && zmnUtil.isEmptyNull(data.theChiefUrl)){
            layer.msg("考试链接不能全部为空", {"icon": 2});
            return false;
        }

        $.ajax({
            async: false,
            type: "POST", url: url,
            contentType: "application/json", dataType: "json", data: JSON.stringify(data),
            success:function(result) {
                if(result.status == 200) {
                    parent.reload(result.message, false);
                    cancel();
                } else {
                    layui.layer.msg(result.message,{"icon":2});
                }
            },
            error:function(XMLHttpRequest, textStatus, errorThrown){
            }
        })
        return false;
    });
    //对外暴露的接口
    exports('plat_engineerexamineurl_detail', {});
});

// 取消
function cancel() {
    let index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
    parent.layer.close(index);
}